home *** CD-ROM | disk | FTP | other *** search
- // Listing 8 - Functions to lock and unlock records
- // (See Listing 3 for the class definition)
- // These functions use Turbo C MS-DOS locking facilities
-
- // =============================================
- // Function to lock a record if the file was opened with
- // shared write access allowed from other programs
- //
- int binaryfile::lockrecord (long number) {
- if (share != WriteShared) return 0;
- if (locked > 0L) unlockrecord(); // Unlock currently locked record
- return (lock (handle, // Turbo C lock function
- (((locked = number) - 1) * length) + header, length) ?
- (int)(locked = -1L) : 0);
- }
-
- // =============================================
- // Function to unlock a record if currently locked
- //
- void binaryfile::unlockrecord () {
- if (share != WriteShared || locked <= 0L) return;
- locked = (long) unlock (handle, // Turbo C unlock function
- ((locked - 1) * length) + header, length);
- }
-
- // End of file
-